<template><div><h2 id="测试-入门" tabindex="-1"><a class="header-anchor" href="#测试-入门"><span>测试：入门</span></a></h2>
<ul>
<li><a href="#introduction">介绍</a></li>
<li><a href="#environment">环境</a></li>
<li><a href="#creating-tests">创建测试</a></li>
<li><a href="#running-tests">运行测试</a>
<ul>
<li><a href="#running-tests-in-parallel">并行运行测试</a></li>
<li><a href="#reporting-test-coverage">测试覆盖率报告</a></li>
<li><a href="#profiling-tests">性能分析测试</a></li>
</ul>
</li>
</ul>
<h2 id="介绍" tabindex="-1"><a class="header-anchor" href="#介绍"><span>介绍</span></a></h2>
<p><code v-pre>Laravel</code> 在构建时考虑到了测试。实际上，对 <code v-pre>PHPUnit</code> 测试的支持是开箱即用的，并且已经为你的应用程序设置了一个 <code v-pre>phpunit.xml</code> 文件。 <code v-pre>Laravel</code>还附带了方便的帮助方法，允许你对应用程序进行富有表现力的测试。</p>
<p>默认情况下，你应用程序的<code v-pre>tests</code>目录下包含两个子目录：<code v-pre>Feature</code> 和 <code v-pre>Unit</code>。<strong>单元测试</strong>（<code v-pre>Unit</code>）是针对你的代码中非常少，而且相对独立的一部分代码来进行的测试。实际上，大部分单元测试都是针对单个方法进行的。在你的 <code v-pre>Unit</code> 测试目录中进行测试，不会启动你的 <code v-pre>Laravel</code> 应用程序，因此无法访问你的应用程序的数据库或其他框架服务。</p>
<p><strong>功能测试</strong>（<code v-pre>Feature</code>）能测试你的大部分代码，包括多个对象如何相互交互，甚至是对 <code v-pre>JSON</code> 端点的完整 <code v-pre>HTTP</code> 请求。 <strong>通常，你的大多数测试应该是功能测试。这些类型的测试可以最大程度地确保你的系统作为一个整体按预期运行。</strong></p>
<p><code v-pre>Feature</code> 和 <code v-pre>Unit</code> 测试目录中都提供了一个 <code v-pre>ExampleTest.php</code> 文件。 安装新的 Laravel 应用程序后，执行 <code v-pre>vendor/bin/phpunit</code> 或 <code v-pre>php artisan test</code> 命令来运行你的测试。</p>
<h2 id="环境" tabindex="-1"><a class="header-anchor" href="#环境"><span>环境</span></a></h2>
<p>运行测试时，由于 <code v-pre>phpunit.xml</code> 文件中定义了 <a href="https://learnku.com/docs/laravel/10.x/configuration#environment-configuration" target="_blank" rel="noopener noreferrer">环境变量</a> ，<code v-pre>Laravel</code> 会自动配置环境变量为 <code v-pre>testing</code>。<code v-pre>Laravel</code> 还会在测试时自动将会话和缓存配置到 <code v-pre>array</code> 驱动程序，这意味着在测试时不会持久化会话或缓存数据。</p>
<p>你可以根据需要自由定义其他测试环境配置值。 <code v-pre>testing</code> 环境变量可以在应用程序的 <code v-pre>phpunit.xml</code> 文件中配置，但请确保在运行测试之前使用 <code v-pre>config:clear</code> Artisan 命令清除配置缓存！</p>
<h4 id="env-testing-环境配置文件" tabindex="-1"><a class="header-anchor" href="#env-testing-环境配置文件"><span><code v-pre>.env.testing</code> 环境配置文件</span></a></h4>
<p>此外，你可以在项目的根目录中创建一个 <code v-pre>.env.testing</code> 文件。 当运行 <code v-pre>PHPUnit</code> 测试或使用 <code v-pre>--env=testing</code> 选项执行 Artisan 命令时，将不会使用 <code v-pre>.env</code> 文件，而是使用此文件。</p>
<h4 id="createsapplication-trait" tabindex="-1"><a class="header-anchor" href="#createsapplication-trait"><span><code v-pre>CreatesApplication</code> Trait</span></a></h4>
<p>Laravel 包含一个 <code v-pre>CreatesApplication</code> Trait，该<code v-pre>Trait</code>应用于应用程序的基类 <code v-pre>TestCase</code> 。 这个 <code v-pre>trait</code> 包含一个 <code v-pre>createApplication</code> 方法，它在运行测试之前引导 Laravel 应用程序。 重要的是，应将此 <code v-pre>trait</code> 保留在其原始位置，因为某些功能（例如 <code v-pre>Laravel</code> 的并行测试功能）依赖于它。</p>
<h2 id="创建测试" tabindex="-1"><a class="header-anchor" href="#创建测试"><span>创建测试</span></a></h2>
<p>要创建新的测试用例，请使用Artisan 命令： <code v-pre>make:test</code> 。 默认情况下，测试将放置在 <code v-pre>tests/Feature</code> 目录中：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan make:test UserTest</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果想在 <code v-pre>tests/Unit</code> 目录中创建一个测试，你可以在执行 <code v-pre>make:test</code> 命令时使用 <code v-pre>--unit</code> 选项：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan make:test UserTest <span class="token parameter variable">--unit</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果想创建一个 <a href="https://pestphp.com/" target="_blank" rel="noopener noreferrer">Pest PHP</a> 测试, 你可以为 <code v-pre>make:test</code> 命令提供 <code v-pre>--pest</code> 选项：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan make:test UserTest <span class="token parameter variable">--pest</span></span>
<span class="line">php artisan make:test UserTest <span class="token parameter variable">--unit</span> <span class="token parameter variable">--pest</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p><strong>技巧</strong><br>
可以使用 <a href="https://learnku.com/docs/laravel/10.x/artisan#stub-customization" target="_blank" rel="noopener noreferrer">Stub 定制</a>来自定义测试。</p>
</blockquote>
<p>生成测试后，你可以像通常使用 <a href="https://phpunit.de/" target="_blank" rel="noopener noreferrer">PHPUnit</a> 那样定义测试方法。要运行测试，请从终端执行 <code v-pre>vendor/bin/phpunit</code>或 <code v-pre>php artisan test</code> 命令：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> Tests\\Unit<span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> PHPUnit\\Framework\\TestCase<span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">ExampleTest</span> <span class="token keyword">extends</span> <span class="token class-name">TestCase</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 基础测试样例</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">test_basic_test</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">assertTrue</span><span class="token punctuation">(</span><span class="token constant boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>注意：如果你在测试类中定义自己的 <code v-pre>setUp</code>  或 <code v-pre>tearDown</code>  方法，请务必在父类上调用各自的 <code v-pre>parent::setUp()</code>  或 <code v-pre>parent::tearDown()</code>  方法。</p>
</blockquote>
<p><strong><strong>运行测试</strong></strong></p>
<p>正如前面提到的，编写测试后，可以使用 <code v-pre>phpunit</code>  命令来执行测试：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">./vendor/bin/phpunit</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>除了 <code v-pre>phpunit</code>  命令，你还可以使用 <code v-pre>test</code>  Artisan 命令来运行你的测试。 Artisan 测试运行器提供了详细的测试报告，以简化开发和调试：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan <span class="token builtin class-name">test</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>任何可以传递给 <code v-pre>phpunit</code>  命令的参数也可以传递给 Artisan <code v-pre>test</code>  命令：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan <span class="token builtin class-name">test</span> <span class="token parameter variable">--testsuite</span><span class="token operator">=</span>Feature --stop-on-failure</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong><strong>并行运行测试</strong></strong></p>
<p>默认情况下，<code v-pre>Laravel</code>  和 <code v-pre>PHPUnit</code>  在执行测试时，是在单进程中按照先后顺序执行的。除此之外，通过多个进程同时运行测试，则可以大大减少运行测试所需的时间。首先，请确保你的应用程序已依赖于 <code v-pre>^5.3</code>  或更高版本的 <code v-pre>nunomaduro/collision</code>  依赖包。然后，在执行 <code v-pre>test</code>  Artisan 命令时，请加入 <code v-pre>--parallel</code>  选项：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan <span class="token builtin class-name">test</span> <span class="token parameter variable">--parallel</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>默认情况下，<code v-pre>Laravel</code>  将创建与计算机上可用 CPU 内核数量一样多的进程。但是，你可以使用 <code v-pre>--processes</code>  选项来调整进程数：</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line">php artisan <span class="token builtin class-name">test</span> <span class="token parameter variable">--parallel</span> <span class="token parameter variable">--processes</span><span class="token operator">=</span><span class="token number">4</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><blockquote>
<p>注意：在并行测试时，某些 PHPUnit 选项（例如 <code v-pre>--do-not-cache-result</code> ）可能不可用。</p>
</blockquote>
<h3 id="并行测试和数据库" tabindex="-1"><a class="header-anchor" href="#并行测试和数据库"><span><strong>并行测试和数据库</strong></span></a></h3>
<p><code v-pre>Laravel</code> 在执行并行测试时，自动为每个进程创建并迁移生成一个测试数据库。这些测试数据库将以每个进程唯一的进程令牌作为后缀。例如，如果你有两个并行的测试进程，<code v-pre>Laravel</code> 将创建并使用 <code v-pre>your_db_test_1</code> 和 <code v-pre>your_db_test_2</code> 测试数据库。</p>
<p>默认情况下，在多次调用 <code v-pre>test</code> Artisan 命令时，上一次的测试数据库依然存在，以便下一次的 <code v-pre>test</code> 命令可以再次使用它们。但是，你可以使用 <code v-pre>--recreate-databases</code> 选项重新创建它们：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan test <span class="token operator">--</span>parallel <span class="token operator">--</span>recreate<span class="token operator">-</span>databases</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="并行测试钩子" tabindex="-1"><a class="header-anchor" href="#并行测试钩子"><span><strong>并行测试钩子</strong></span></a></h3>
<p>有时，你可能需要为应用程序测试准备某些资源，以便可以将它们安全地用于多个测试进程。</p>
<p>使用 <code v-pre>ParallelTesting</code> 门面，你就可以在进程或测试用例的 <code v-pre>setUp</code> 和 <code v-pre>tearDown</code> 上指定要执行的代码。给定的闭包将分别接收包含进程令牌和当前测试用例的 <code v-pre>$token</code> 和 <code v-pre>$testCase</code> 变量：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Providers</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Support<span class="token punctuation">\</span>Facades<span class="token punctuation">\</span>Artisan</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Support<span class="token punctuation">\</span>Facades<span class="token punctuation">\</span>ParallelTesting</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Support<span class="token punctuation">\</span>ServiceProvider</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">AppServiceProvider</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceProvider</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 引导任何应用程序服务。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">boot</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">setUpProcess</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$token</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// ...</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">setUpTestCase</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$token</span><span class="token punctuation">,</span> <span class="token variable">$testCase</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// ...</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 在创建测试数据库时执行……</span></span>
<span class="line">        <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">setUpTestDatabase</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$database</span><span class="token punctuation">,</span> <span class="token variable">$token</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token class-name static-context">Artisan</span><span class="token operator">::</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'db:seed'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">tearDownTestCase</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$token</span><span class="token punctuation">,</span> <span class="token variable">$testCase</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// ...</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">tearDownProcess</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$token</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// ...</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="访问并行测试令牌" tabindex="-1"><a class="header-anchor" href="#访问并行测试令牌"><span><strong>访问并行测试令牌</strong></span></a></h3>
<p>如果你想从应用程序的测试代码中的任何其他位置访问当前的并行进程的 <code v-pre>token</code>，则可以使用 <code v-pre>token</code> 方法。该令牌（<code v-pre>token</code>）是单个测试进程的唯一字符串标识符，可用于在并行测试过程中划分资源。例如，<code v-pre>Laravel</code> 自动用此令牌值作为每个并行测试进程创建的测试数据库名的后缀：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$token</span> <span class="token operator">=</span> <span class="token class-name static-context">ParallelTesting</span><span class="token operator">::</span><span class="token function">token</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="报告测试覆盖率" tabindex="-1"><a class="header-anchor" href="#报告测试覆盖率"><span><strong>报告测试覆盖率</strong></span></a></h3>
<blockquote>
<p>注意：这个功能需要 Xdebug 或 PCOV。</p>
</blockquote>
<p>在运行测试时，你可能需要确定测试用例是否真的测到了某些程序代码，以及在运行测试时究竟使用了多少应用程序代码。要实现这一点，你可以在调用 <code v-pre>test</code> 命令时，增加一个 <code v-pre>--coverage</code> 选项：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan test <span class="token operator">--</span>coverage</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="最小覆盖率阈值限制" tabindex="-1"><a class="header-anchor" href="#最小覆盖率阈值限制"><span><strong>最小覆盖率阈值限制</strong></span></a></h3>
<p>你可以使用 <code v-pre>--min</code> 选项来为你的应用程序定义一个最小测试覆盖率阈值。如果不满足此阈值，测试套件将失败：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan test <span class="token operator">--</span>coverage <span class="token operator">--</span>min<span class="token operator">=</span><span class="token number">80.3</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="测试性能分析" tabindex="-1"><a class="header-anchor" href="#测试性能分析"><span>测试性能分析</span></a></h3>
<p>Artisan 测试运行器还提供了一个方便的机制用于列出你的应用程序中最慢的测试。使用<code v-pre>--profile</code>选项调用测试命令，可以看到10个最慢的测试列表，这可以让你很容易地识别哪些测试可以被改进，以加快你的测试套件。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan test <span class="token operator">--</span>profile</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><blockquote>
<p>本译文仅用于学习和交流目的，转载请务必注明文章译者、出处、和本文链接<br>
我们的翻译工作遵照 <a href="https://learnku.com/docs/guide/cc4.0/6589" target="_blank" rel="noopener noreferrer">CC 协议</a>，如果我们的工作有侵犯到您的权益，请及时联系我们。</p>
</blockquote>
<hr>
<blockquote>
<p>原文地址：<a href="https://learnku.com/docs/laravel/10.x/testing/14895" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/10.x/te...</a></p>
<p>译文地址：<a href="https://learnku.com/docs/laravel/10.x/testing/14895" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/10.x/te...</a></p>
</blockquote>
</div></template>


